package com.qianli.cashmama.trade.dao.impl;

import com.fqgj.common.api.Page;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.common.utils.StringUtils;
import com.qianli.cashmama.trade.dao.TTimeoutCenterDao;
import com.qianli.cashmama.trade.entity.TTimeoutCenterEntity;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: sm
 * Date: 2017-07-21
 * Time: 09:10:21.150
 */

@Repository
public class TTimeoutCenterDaoImpl extends AbstractBaseMapper<TTimeoutCenterEntity> implements TTimeoutCenterDao {

    @Override
    public List<TTimeoutCenterEntity> selectListByPageAndDate(Page page, Date date, Integer type, Integer shardingItem) {
        Map<String, Object> map = new HashMap<>();
        map.put("triggerTime", date);
        map.put("page", page);
        map.put("shardingItem", shardingItem);
        map.put("type", type);
        return getSqlSession().selectList(getStatement("selectListByPageAndDate"), map);
    }

    @Override
    public int countByValueAndType(String value, Integer type, Integer deleted) {
        Map<String, Object> map = new HashMap<>();
        map.put("value", value);
        map.put("type", type);
        map.put("deleted", deleted);
        return getSqlSession().selectOne(getStatement("countByValueAndType"), map);
    }

    @Override
    public int deleteHisDeductTask(String billNo) {
        if (StringUtils.isEmpty(billNo)) {
            return 0;
        }
        Map<String, Object> map = new HashMap<>();
        map.put("billNo", billNo);
        return getSqlSession().update(getStatement("deleteHisDeductTask"), map);
    }
}